package xuegao.study.mall.admin.feign;

import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import xuegao.study.mall.common.api.CommonPage;
import xuegao.study.mall.common.api.CommonResult;
import xuegao.study.mall.common.model.ums.UmsMenu;
import xuegao.study.mall.common.vo.ums.UmsMenuVo;

import java.util.List;

@FeignClient(contextId = "menu", name = "study-rbac-service", path = "/rbac/menu")
public interface UmsMenuClient {

    @ApiOperation("创建菜单")
    @PostMapping("/create")
    CommonResult<Integer> addMenu(@RequestBody UmsMenu menu);

    @ApiOperation("删除菜单")
    @DeleteMapping("/delete/{id}")
    CommonResult<Integer> deleteMenu(@PathVariable("id") Long id);

    @ApiOperation("更新菜单")
    @PostMapping("/update/{id}")
    CommonResult<Integer> updateMenu(@PathVariable("id") Long id, @RequestBody UmsMenu menu);

    @ApiOperation("查询菜单")
    @GetMapping("/list/{parentId}")
    CommonResult<CommonPage<UmsMenu>> listMenu(
            @PathVariable("parentId") Long parentId,
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize);

    @ApiOperation("树形菜单")
    @GetMapping("/treeList")
    CommonResult<List<UmsMenuVo>> treeList();

    @ApiOperation("根据id获取菜单详情")
    @GetMapping("/{id}")
    CommonResult<UmsMenu> getMenu(@PathVariable("id") Long id);
}
